<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh_cn">
<head>
    <meta charset="UTF-8"/>
    <title>添加分类</title>
    <div th:include="/blog/public/head::head"></div>

</head>
<body>
<form id="articleType" action="/article/type/add" method="post" th:object="${articleType}">
    <div class="layui-form-item">
        <input class="layui-input" style="display: inline; width: 80%"  placeholder="分类名称" th:field="*{typeName}" type="text" />
        <button class="layui-btn" style="width: 19%" type="button" onclick="addArticleType('#articleType')">添加</button>
        <span th:if="${#fields.hasErrors('typeName')}"
              th:errors="*{typeName}">
            </span>
    </div>
    <input name="userId" th:value="${userId}" type="hidden"/>
    <input th:field="*{id}" type="hidden"/>
</form>
<hr/>
<table class="layui-table">
    <tr th:each="type:${type}">
        <td th:text="${type.typeName}"></td>
    </tr>
</table>
<script>
    function addArticleType(id) {
        addSubmit(id)
        $('.layui-table').load("/article/type/list");
    }
</script>
</body>
</html>